package design.Day02;

/**
* @description: 预测信息
* @author: wangjun
* @create: 2022-01-11
*/
public class ForecastDisplay implements Observer,DisplayElement{

    private Subject subject;

    private float temp;
    private float humidity;
    private float pressure;

    public void setSubject(Subject subject) {
        this.subject = subject;
        subject.registerObserver(this);
    }

    @Override
    public void display() {
        System.out.println("ForecastDisplay --> Forecast temp: " + temp + " Forecast humidity: " + humidity + " Forecast pressure: " + pressure);
    }

    @Override
    public void update(float temp, float humidity, float pressure) {
        this.temp = temp;
        this.humidity = humidity;
        this.pressure = pressure;
        display();
    }
}
